package com.aiit.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Getter
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVO<T> implements Serializable {
    // Getter
    private int code;
    private String message;
    private T data;

    // 构造方法
//    private ResultVO(int code, String message, T data) {
//        this.code = code;
//        this.message = message;
//        this.data = data;
//    }

    // 成功无数据
    public static <T> ResultVO<T> success() {
        return new ResultVO<>(200, "成功", null);
    }

    // 成功带数据
    public static <T> ResultVO<T> success(T data) {
        return new ResultVO<>(200, "成功", data);
    }

    // 失败
    public static <T> ResultVO<T> error(String message) {
        return new ResultVO<>(400, message, null);
    }

}